<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/iframetemplete.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  <script type="text/javascript" src="/Jupiter/ext-4.0/ext-debug.js"></script> 
  <link rel="stylesheet" type="text/css" href="/Jupiter/ext-4.0/resources/css/ext-all.css" /> 
  <link rel="stylesheet" type="text/css" href="/Jupiter/css/main.css" /> 
  <script type="text/javascript" src="/Jupiter/js/json2.js"></script>
  <link href="/Jupiter/css/gy/top.css" rel="stylesheet" type="text/css" />
  <link href="/Jupiter/css/gy/left.css" rel="stylesheet" type="text/css" />
  <link href="/Jupiter/css/main.css" rel="stylesheet" type="text/css" />
  <link href="/Jupiter/css/sy.css" rel="stylesheet" type="text/css" />  
</head>

<body id="sy">
<!-- InstanceBeginEditable name="EditRegion3" -->
<script type="text/javascript">
Ext.Loader.setConfig({
    enabled: true
});
Ext.Loader.setPath('Ext.ux', '/Jupiter/ext/ux');
Ext.require(['Ext.grid.*', 'Ext.data.*', 'Ext.util.*', 'Ext.state.*', 'Ext.form.*', 'Ext.ux.CheckColumn',
'Ext.ux.grid.FiltersFeature', 'Ext.toolbar.Paging']);
Ext.onReady(function(){
	var store = Ext.create('Ext.data.Store', {
	    "storeId": "store",
	    "fields": ["file", "user", "create_at"],
	    "autoLoad": true,
	    "pageSize": 22,
	    "proxy": {
	        "type": "ajax",
	        "url": "\/material\/getimporthistory",
	        "reader": {
	            "type": "json",
	            "root": "source",
		        "totalProperty": "totalCount"
	        }
	    }
	});
	var grid = Ext.create('Ext.grid.Panel', {
	    "store": "store",
	    "dockedItems": [{
	        "xtype": "pagingtoolbar",
	        "store": "store",
	        "dock": "bottom",
	        "displayInfo": true
	    }],
	    "features": [{
	        "ftype": "grouping"
	    }, {
	        "ftype": "filters"
	    }],
	    "columns": [{
	        "text": "文件名",
	        "dataIndex": "file",
	        "filter": {
	            "type": "string",
	            "dataIndex": "d.file"
	        }
	    }, {
	        "text": "操作人",
	        "dataIndex": "user",
	        "filter": {
	            "type": "string",
	            "dataIndex": "d.user"
	        }
	    }, {
	        "text": "导入时间",
	        "dataIndex": "create_at",
	        "renderer": "function(value){if(value)return value['date'];}",
	        "filter": {
	            "type": "date",
	            "dataIndex": "d.create_at"
	        }
	    }],
	    "height":365,
	});
	var upload = Ext.create('Ext.form.Panel', {
	    title: '请选择',
	    width: 400,
	    frame: true,
        url: '/Material/import',
	    margin:'0 0 10 0',
	    items: [{
	        xtype: 'filefield',
	        name: 'file',
	        fieldLabel: '上传',
	        labelWidth: 50,
	        msgTarget: 'side',
	        allowBlank: false,
	        anchor: '100%',
	        buttonText: '选择文件',
		    text:"123123"
	    }],
	
	    buttons: [{
	        text: '上传',
	        handler: function() {
	            var form = this.up('form').getForm();
	            if(form.isValid()){
	                form.submit({
	                    waitMsg: '正在导入文件...',
	                    success: function(form, action) {
	                    	Extux.msg('上传成功', ''); 
	                      	form.findField('file').setRawValue('');
	                      	store.load();
	                    },
	                    failure: function(form, action) {
	                    	Extux.msg('上传失败，请查看错误日志', ''); 
	                      	form.findField('file').setRawValue('');
	                      	store.load();
			            }
	                });
	            }
	        }
	    }]
	});
	
	var panel = Ext.create('Ext.Panel',{
		title:'导入Excel',
		frame:true,
		items:[{
			xtype:"label",
			text:"导入须知：需要excel2007的文件格式,在导入前请确认供应商、材料单位和材料品牌都已存在，且一个材料一个品牌，如果导入失败，请查看导入日志，需要保证每个材料都有属性。"
			},upload,grid],
	    renderTo: 'upload',
	});
});	
</script>
<div id="upload"></div>
<!-- InstanceEndEditable -->
</body>
<!-- InstanceEnd --></html>
